package com.sikhyeon.datastructure.controller;

import javafx.event.ActionEvent;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.IOException;

public class MainController {
    private void loadView(ActionEvent event, String viewName) throws IOException {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("/com/sikhyeon/datastructure/view/" + viewName + ".fxml"));
        Parent root = loader.load();
        Stage stage = (Stage) ((Parent) event.getSource()).getScene().getWindow();
        Scene scene = new Scene(root, 800, 600); // 창 크기를 고정
        stage.setScene(scene);
        stage.show();
    }

    public void showStack(ActionEvent event) throws IOException {
        loadView(event, "StackView");
    }

    public void showQueue(ActionEvent event) throws IOException {
        loadView(event, "QueueView");
    }


    public void showThreadedTree(ActionEvent event) throws IOException {
        loadView(event, "ThreadedBinaryTreeView");
    }

    public void showPriorityQueue(ActionEvent event) throws IOException {
        loadView(event, "PriorityQueueView");
    }

    public void showLinkedList(ActionEvent event) throws IOException {
        loadView(event, "LinkedListView");
    }
    public void showBinarySearchTree(ActionEvent event) throws IOException {
        loadView(event, "BinarySearchTreeView");
    }
}
